﻿#Find Chia Blockchain Path
$host.ui.RawUI.WindowTitle="Share Chia FullNode Tool v1.2"
$UserPath = $env:USERPROFILE+"\AppData\Local\chia-blockchain\"
$ChiaVer = Get-ChildItem $UserPath -Directory | Select-String "app-"
$ChiaPath = $UserPath+$ChiaVer+"\resources\app.asar.unpacked\daemon"
$NodePath = Split-Path -Parent $MyInvocation.MyCommand.Definition
#$NodeFile = (Get-Content $NodePath\Share_Chia_FullNode.txt) | Foreach-Object {
#    $_ -replace "^","$ChiaPath\chia.exe "
#}
$NodeFile = (Invoke-webrequest -URI "https://gitee.com/mysical/node/raw/main/new_node.txt").content | Foreach-Object {
    $_ -replace "chia_program_path","$ChiaPath\chia.exe"
}  
""
"============        全节点同步工具          ==========="
""
"这个过程比较长，如果你觉得导入的差不多了可以直接关掉窗口"
"出现连接失败的节点可以不用管他，可能有多个因素导致的失败"
"感谢UP主 - 元気矿工 提供v1.1版本"
""
""
Write-Warning "Share Chia FullNode Tool v1.2"
Write-Warning "准备开始导入同步节点。。。。。。。。"
Write-Warning "请注意观察Chia节点窗口的节点添加数量"
#Start SyncNode
foreach ( $SyncNode in $NodeFile){
     Start-Process powershell.exe -ArgumentList $SyncNode -NoNewWindow
     $SyncPeers
}